#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

int main(){
  pid_t id=fork();
  if(id==0){
    printf("I am child.pid:%d,ppid:%d\n",getpid(),getppid());
    char* const myargv[]={
      "otherExe",
      "-a",
      "-b",
      "-c",
      NULL
    };
    char* const myenv[]={
      "MYVAL=123",
      "MYPATH=/bin",
      NULL
    };
    execve("./otherExe",myargv,myenv);
    printf("I am child after\n");
    exit(5);
  }
  pid_t ret=waitpid(id,NULL,0);
  if(ret)printf("wait success.father pid:%d,child id:%d\n",getpid(),ret);
  return 0;
}
